package com.wsoft.hr.pm.controller;

import com.github.pagehelper.PageInfo;
import com.wsoft.hr.pm.entity.HrPmWarningEntity;
import com.wsoft.hr.pm.query.warning.WarningListQuery;
import com.wsoft.hr.pm.service.IHrPmWarningService;
import com.wsoft.response.ResponsePage;
import com.wsoft.response.ResponseResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 预警表 前端控制器
 * @author Z001
 * @since 2025年03月07日 09:44:46
 */
@RestController
@Tag(name = "预警")
@RequestMapping("/hr/pm/warning")
public class HrPmWarningController {

    @Resource
    private IHrPmWarningService warningService;

    @Operation(summary = "预警列表查询", description = "预警列表查询")
    @PostMapping("/list")
    public ResponseResult list(@RequestBody WarningListQuery query) {
        PageInfo<HrPmWarningEntity> page = warningService.listWarning(query);
        return ResponseResult.success(ResponsePage.restPage(page));
    }


    @Operation(summary = "预警详情", description = "预警详情")
    @GetMapping("/get")
    public ResponseResult get(@RequestParam("id") Long id) {
        return ResponseResult.success(warningService.getWarningInfo(id));
    }


    @Operation(summary = "删除预警", description = "删除预警")
    @GetMapping("/delete")
    public ResponseResult delete(@RequestParam("id") Long id) {
        boolean b = warningService.delete(id);
        if (b) {
            return ResponseResult.success("[sys.msg.success]");
        } else {
            return ResponseResult.failed("[sys.msg.failed]");
        }
    }
}
